import { db } from "src/config/database";
import { add, remove, modify, queryOne } from "./base";

const tableName = "project_info";

function query(fields: string[]) {
  const column_st = fields.join(",");
  const statement = `SELECT ${column_st} FROM  ${tableName} WHERE del_flag = 1 ORDER BY id DESC`;
  return new Promise((resolve, reject) => {
    db!.all(statement, (err, rows) => {
      err ? reject(err) : resolve(rows);
    });
  });
}

export default {
  add: add.bind(null, tableName),
  remove: remove.bind(null, tableName),
  modify: modify.bind(null, tableName),
  queryOne: queryOne.bind(null, tableName),
  query,
};
